package com.gitee.wsl.flow.base

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter

suspend fun <T, C : MutableCollection<in T>> Flow<T>.toCollection(destination: C): C {
    collect { value ->
        destination.add(value)
    }
    return destination
}

fun <T, C : Collection<T>> Flow<C>.filterNotEmpty(): Flow<C> = filter { !it.isEmpty() }
